<%@ page contentType="text/html; charset=utf-8" import="java.net.InetAddress,java.sql.*,java.util.*,com.java.util.*,com.java.model.UserSession,com.java.db.*,com.java.service.*,java.text.DecimalFormat"%>
<jsp:include page="/mobile/common/head.jsp"></jsp:include>
<%
 
String user_name = "";

String  url			= (String) request.getServerName().trim().replace("http://", "");
String train_url 		= request.getServerName();

UserSession usersession = (UserSession)session.getAttribute("user");
String ent_id 			= (String)session.getAttribute("ent_id");

if(usersession != null){
	user_name = usersession.getUser_name();
}

String connGroup 	= "";
String user_id 		= "";
if(usersession!=null){
	connGroup 	= CmmUtil.nvl(usersession.getConnGroup(),"0");
	user_id 	= CmmUtil.nvl(usersession.getUser_id(),"");
}

Calendar now = Calendar.getInstance();
String year     = String.valueOf(now.get(Calendar.YEAR));
String month    = String.valueOf(now.get(Calendar.MONTH)+1);
String curDay   = String.valueOf(now.get(Calendar.DATE));

if(month.length() == 1){
	month = 0 + month;
}

if(curDay.length() == 1){
	curDay = 0 + curDay;
}

now.add(Calendar.MONTH,-1);

String b_year     = String.valueOf(now.get(Calendar.YEAR));
String b_month    = String.valueOf(now.get(Calendar.MONTH)+1);
String b_curDay   = String.valueOf(now.get(Calendar.DATE));

if(b_month.length() == 1){
	b_month = 0 + b_month;
}

if(b_curDay.length() == 1){
	b_curDay = 0 + b_curDay;
}

String start_dt = CmmUtil.nvl(request.getParameter("start_dt"),b_year + b_month + b_curDay);
String close_dt = CmmUtil.nvl(request.getParameter("close_dt"),year + month + curDay);

/*
String present_Year = String.valueOf(GregorianCalendar.getInstance().get(Calendar.YEAR));
//GregorianCalendar에서 1월 return 값이 0이므로 Month에는  1을 더해주어야 함
String present_Month = String.valueOf(GregorianCalendar.getInstance().get(Calendar.MONTH)+1); 
String present_Date 	= String.valueOf(GregorianCalendar.getInstance().get(Calendar.DATE));

if(present_Month.length() == 1){
	present_Month = "0" + present_Month; //01월,02월 ..... 09월
}

GregorianCalendar g = new GregorianCalendar();
g.add(Calendar.MONTH, 0);

String befor_Month = String.valueOf(g.get(Calendar.MONTH));

if(befor_Month.length() == 1){
	befor_Month = "0" + befor_Month; //01월,02월 ..... 09월
}

if(present_Date.length() == 1){
	present_Date = "0" + present_Date; //01일,02일 ..... 09일
}

String start_dt = CmmUtil.nvl(request.getParameter("start_dt"),present_Year + befor_Month + present_Date);
String close_dt = CmmUtil.nvl(request.getParameter("close_dt"),present_Year + present_Month + present_Date);
*/
 	
HashMap map = new HashMap();
HashMap map1 = null;
HashMap map2 = null;


ArrayList list = new ArrayList();
ArrayList list1 = new ArrayList();
ArrayList list2 = new ArrayList();

CommonDaoService commonservice = new CommonDaoService("Com0101lp02Dao");

map.put("ent_id",ent_id);
map.put("start_dt",start_dt);
map.put("close_dt",close_dt);
map.put("user_id",user_id);


list = (ArrayList)commonservice.commonDaoMethod(map);

String kisu_app_cnt ="";
String kisu_noapp_cnt ="";
String kisu_cancel_cnt ="";
String sang_app_cnt ="";
String sang_noapp_cnt ="";
String sang_cancel_cnt ="";
String lect_amt_kisu ="";
String lect_amt_sang ="";
String ret_amt_kisu ="";

String poi_cnt ="";
String kisu_member_cnt ="";
String sang_member_cnt ="";
String kisu_poi_cnt ="";
String sang_poi_cnt ="";
String lect_amt_kisu_sugang ="";
String lect_amt_sang_sugang ="";
String ret_amt_kisu_sugang ="";

if(list != null){
	if(list.size() > 0){
		list1 = (ArrayList)list.get(0);
		
		kisu_app_cnt = (String)((HashMap)list1.get(0)).get("kisu_app_cnt");
		kisu_noapp_cnt = (String)((HashMap)list1.get(0)).get("kisu_noapp_cnt");
		kisu_cancel_cnt = (String)((HashMap)list1.get(0)).get("kisu_cancel_cnt");
		sang_app_cnt = (String)((HashMap)list1.get(0)).get("sang_app_cnt");
		sang_noapp_cnt = (String)((HashMap)list1.get(0)).get("sang_noapp_cnt");
		sang_cancel_cnt = (String)((HashMap)list1.get(0)).get("sang_cancel_cnt");
		lect_amt_kisu = (String)((HashMap)list1.get(0)).get("lect_amt_kisu");
		lect_amt_sang = (String)((HashMap)list1.get(0)).get("lect_amt_sang");
		ret_amt_kisu = (String)((HashMap)list1.get(0)).get("ret_amt_kisu");
	}
	if(list.size() > 1){
		list2 = (ArrayList)list.get(1);
		
		poi_cnt = CmmUtil.nvl((String)((HashMap)list2.get(0)).get("poi_cnt"),"0");
		kisu_member_cnt = (String)((HashMap)list2.get(0)).get("kisu_member_cnt");
		sang_member_cnt = (String)((HashMap)list2.get(0)).get("sang_member_cnt");
		kisu_poi_cnt = CmmUtil.nvl((String)((HashMap)list2.get(0)).get("kisu_poi_cnt"),"0");
		sang_poi_cnt = CmmUtil.nvl((String)((HashMap)list2.get(0)).get("sang_poi_cnt"),"0");
		lect_amt_kisu_sugang = (String)((HashMap)list2.get(0)).get("lect_amt_kisu");
		lect_amt_sang_sugang = (String)((HashMap)list2.get(0)).get("lect_amt_sang");
		ret_amt_kisu_sugang = (String)((HashMap)list2.get(0)).get("ret_amt_kisu");
	}		
}

/*
Connection con=null;
ArrayList list =null;
HashMap userMap = new HashMap();
try {
	String user_ip   = request.getRemoteAddr();
	
	con = (new CommonConnect()).getConnection_ds1();
	String[] param=null;
	String queryStr = "call stu_eduLogin_Mobile(?,?,?,?)";
	param= new String[4];
	param[0] = login_id;
	param[1] = login_pwd;
	param[2] = url;
	param[3] = user_ip;
	
	list = DaoUtils.select(con,queryStr,param);
	if (list==null || list.size()==0){
		request.setAttribute("login_message","ID is not member or Password is wrong!");
		//out.println("<script>alert('ID is not member or Password is wrong!');history.back();</script>");
	}else{
		userMap =(HashMap)list.get(0);
		UserSession userSession = (UserSession) new UserSession( (Map) userMap );
        session.setAttribute( "user", userSession );        
	}
	//System.out.println(list);
	
} catch (Exception e) {
	e.printStackTrace();
}finally {
	  try{
		  if (con!=null) con.close();
	  }catch(Exception ee){}
}

String user_name = "";

for (int i=0; list!=null && list.size() > i; i++){ 
	HashMap map = (HashMap)list.get(i);		
	user_name = CommonUtil.nvl((String)map.get("user_name"));
}
*/

%>

<body>
<div data-role="page" >
<%
if(usersession == null){	
%>
<script>
//location.href='/mobile/index.jsp';
</script>
<%
}else{ 	
%>
	<div data-role="header" data-theme="a" data-backbtn="false" data-position="fixed">
    	<h1><%=user_name %>님 환영합니다.</h1>
    </div>
    <!-- 
    <div data-role="content">
    <ul data-role="listview" data-split-icon="gear">
		<li>
        	<a href="mypage.jsp" rel="external">
			<img src="images/mypage.jpg" width="75" height="75"/> 
			<h3>마이페이지</h3> 
			<p>내정보를 볼 수 있습니다.</p>				
			</a>
            <a href="mypage.jsp" data-rel="dialog" data-transition="slideup" rel="external">mypage</a>
        </li> 
		<li>
        	<a href="notice.jsp" rel="external">
			<img src="images/notice.jpg" width="75" height="75"/> 
			<h3>공지사항</h3> 				
			<p>공지사항으로 이동합니다.</p>				
			</a>
            <a href="notice.jsp" data-rel="dialog" data-transition="slideup" rel="external">notice</a>
        </li> 
        <li>
        	<a href="course_more.jsp" rel="external">
			<img src="images/course.jpg" width="75" height="75"/> 
			<h3>과정정보</h3> 				
			<p>과정목록을 보고 수강신청을 할 수 있습니다.</p>				
			</a>
            <a href="course_more.jsp" data-rel="dialog" data-transition="slideup" rel="external">course</a>
        </li>
        <li>
        	<a href="study.jsp" rel="external">
			<img src="images/study.jpg" width="75" height="75"/> 
			<h3>수강정보</h3> 				
			<p>수강중인 강좌리스트를 볼 수 있습니다.</p>				
			</a>
            <a href="study.jsp" data-rel="dialog" data-transition="slideup" rel="external">study</a>
        </li> 
        
        </ul>
    </div>
    -->
    <p>날짜 : <%=start_dt %> ~ <%=close_dt %>
    <input type='date' name='std_start_dt'>
    </p>
    <p>수강신청 현황</p>
    <div class="ui-grid-c">   
            <div class="ui-block-a"><div class="ui-bar ui-bar-b" >&nbsp;</div></div>
            <div class="ui-block-b"><div class="ui-bar ui-bar-b" >승인</div></div>   
            <div class="ui-block-c"><div class="ui-bar ui-bar-b" >미승인</div></div>   
            <div class="ui-block-d"><div class="ui-bar ui-bar-b"  >취소</div></div>   
    </div>
    
    <div class="ui-grid-c">   
            <div class="ui-block-a"><div class="ui-bar ui-bar-d" >기수형</div></div>
            <div class="ui-block-b"><div class="ui-bar ui-bar-c" ><%=kisu_app_cnt %></div></div>   
            <div class="ui-block-c"><div class="ui-bar ui-bar-c" ><%=kisu_noapp_cnt %></div></div>   
            <div class="ui-block-d"><div class="ui-bar ui-bar-c"  ><%=kisu_cancel_cnt %></div></div>   
    </div>
    
    <div class="ui-grid-c">   
            <div class="ui-block-a"><div class="ui-bar ui-bar-d" >상시형</div></div>
            <div class="ui-block-b"><div class="ui-bar ui-bar-c" ><%=sang_app_cnt %></div></div>   
            <div class="ui-block-c"><div class="ui-bar ui-bar-c" ><%=sang_noapp_cnt %></div></div>   
            <div class="ui-block-d"><div class="ui-bar ui-bar-c"  ><%=sang_cancel_cnt %></div></div>   
    </div>
    
    <p>수강현황</p>
    <div class="ui-grid-c">   
            <div class="ui-block-a"><div class="ui-bar ui-bar-b" >&nbsp;</div></div>
            <div class="ui-block-b"><div class="ui-bar ui-bar-b" >과정수</div></div>   
            <div class="ui-block-c"><div class="ui-bar ui-bar-b" >학습자</div></div>   
            <div class="ui-block-d"><div class="ui-bar ui-bar-b"  >수강료</div></div>   
    </div>
    
    
    <div class="ui-grid-c">  
    		<div class="ui-block-a"><div class="ui-bar ui-bar-d" >기수형</div></div> 
            <div class="ui-block-b"><div class="ui-bar ui-bar-c" ><%=kisu_poi_cnt %></div></div>   
            <div class="ui-block-c"><div class="ui-bar ui-bar-c" ><%=kisu_member_cnt %></div></div>   
            <div class="ui-block-d"><div class="ui-bar ui-bar-c"  ><%=lect_amt_kisu %></div></div>   
    </div>
    
    <div class="ui-grid-c"> 
    		<div class="ui-block-a"><div class="ui-bar ui-bar-d" >상시형</div></div>  
            <div class="ui-block-b"><div class="ui-bar ui-bar-c" ><%=sang_poi_cnt %></div></div>   
            <div class="ui-block-c"><div class="ui-bar ui-bar-c" ><%=sang_member_cnt %></div></div>   
            <div class="ui-block-d"><div class="ui-bar ui-bar-c"  ><%=lect_amt_sang %></div></div>   
    </div>
   
   <jsp:include page="/mobile/common/footer.jsp"></jsp:include>
    
<%
	
}
%>    
</div>
</body>
</html>
